<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
 	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <div class="ibox-title" style="border-color: white;">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="form-group form-inline">
                                <span>姓名:</span>
                                <input id="name" type="text" placeholder="请输入名称" class="input-sm form-control">
                                <span>网站账号:</span>
                                <input id="collector" type="text" placeholder="请输入网站账号" class="input-sm form-control">
                                <a id="find_btn" type="button" class="btn btn-sm btn-primary"> 搜索</a>&nbsp;&nbsp;
	                            <s:hasPermission name="dataCollection:add">
	                             		<a  class="btn btn-sm btn-success" style="margin-left: 20px;" onclick="showadd();"> 添加</a>
	                            </s:hasPermission>
                             </div>
                        </div>
                    </div>
                </div>
                <!-- biaogebigin -->
                <div class="ibox-content" style=" padding-left: 0px; margin-top: 10px;">
                    <div class="jqGrid_wrapper">
                        <table id="table_list"></table>
                        <div id="pager_list"></div>
                    </div>
                </div>
                <!-- tableover -->
            </div>
            <!-- PAGE CONTENT ENDS HERE -->

        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<script type="text/javascript">
    $(top.hangge());
        $.jgrid.defaults.styleUI = "Bootstrap";
        $("#table_list").jqGrid({
            url: '<%=contextPath%>/dataCollection/listData',
            datatype: "json",
            postData: {}, //发送数据
            autowidth: true,
            rownumbers: true,
            shrinkToFit: true,
            mtype: "post",
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: [
			"id",
			"数据来源",
			"网站帐号",
			"姓名",
			"性别",
			"年龄",
			"手机号码",
			"邮箱",
			"工作地点",
			"期望从事职位",
			"期望薪资",
			"目前状态",
			"采集网址",
			"采纳状态",
	         "操作"],
            colModel: [
			{name: "id",index: "id",hidden: true}, 
			{name:"type",index:"type",width:60,
				formatter: function (value, options, row) {
					if(value==1){
						return "<font color='red'>卓聘网<font>";
					}else{
						return "<font color='green'>猎聘网<font>";
					}
				}
			},
			{name:"collector",index:"collector",width:110},
			{name:"name",index:"name",width:60},
			{name:"sex",index:"sex",width:40},
			{name:"age",index:"age",width:50},
			{name:"phone",index:"phone",width:100},
			{name:"email",index:"email",width:100},
			{name:"workPlace",index:"workPlace",width:100},
			{name:"job",index:"job",width:100},
			{name:"salary",index:"salary",width:100},
			{name:"status",index:"status",width:100},
			{name:"url",index:"url",width:100,
				formatter: function (value, options, row) {
						return '<a href="'+value+'" target="_blank">'+value+'</a>';
				}
			},
			{name:"isAdopt",index:"isAdopt",width:60,
				formatter: function (value, options, row) {
					if(value==1){
						return "<font color='red'>未采纳<font>";
					}else{
						return "<font color='green'>已采纳<font>";
					}
				}
			},
	        {
                formatter: function (cellvalue, options, row) {
                	var htm =" <s:hasPermission name="dataCollection:edit"><a class='btn btn-sm btn-warning' title='采纳' onclick='showedit(&quot;" + row.id + "&quot;)'><i class='icon-check'></i></a></s:hasPermission> ";
                	if(row.isAdopt==2){
                		htm ="";
                	}
                    return " <s:hasPermission name="dataCollection:detail"><a class='btn btn-sm btn-info' title='查看' onclick='showeye(&quot;" + row.id + "&quot;)'><i class='icon-eye-open'></i></a></s:hasPermission> " 
                         + htm + " <s:hasPermission name="dataCollection:delete"><a class='btn btn-sm btn-danger' title='删除' onclick='del(&quot;" + row.id + "&quot;)'><i class='icon-trash'></i></a></s:hasPermission> ";
                },
                width: 180
            }],
            height: $(window).height() - 170,
            pager: "#pager_list",
            multiselect: true,//多选按钮
            //multiboxonly: true,
            viewrecords: true,
            hidegrid: false
        });
        //表格自适应高宽
        $(window).bind("resize", function () {
            var b = $(".jqGrid_wrapper").width();
            $("#table_list").setGridWidth(b);
            $("#table_list").setGridHeight($(window).height() - 170);
        })
        $("#table_list").navGrid('#pager_list', {edit: false, add: false, del: false, search: false})
        /* 判断是否有添加权限 */
        //检索
        $("#find_btn").click(function () {
            var name = $("#name").val();
            var collector = $("#collector").val();
            $("#table_list").jqGrid('setGridParam', {
                postData: {'name': name,'collector':collector}, //发送数据
                page: 1
            }).trigger("reloadGrid"); //重新载入
        });
        
    //查看
    function showeye(id) {
        openyem("查看采集数据", "<%=contextPath%>/dataCollection/detailView?id=" + id, 950, 800);
    }
    //删除
    function del(id) {
        swalopen(id, "<%=contextPath%>/dataCollection/delete");
    };
    //修改
    function showedit(id) {
        openyem("填写采纳信息", "<%=contextPath%>/dataCollection/editView?id=" + id, 1080, 850);
    }
</script>
</body>
</html>

